import parentModel from "../parentModel";
export default class logicModel extends parentModel  {
    constructor() {
        super(logicModel,util.api.LogicModel);
        this.table='logicModels';
        this.typeList=['logicDictionary','logicTree','logicQueue','logicSingleton'];
        /** modelMap格式
         * {
            table: tableName,
            featureList: new Set(),
            valueList: new Set(),
            fieldList: new Set(),
            groupList: new Set(),
            fieldMap: {
            fieldname；fieldtype
            },
          }
         */
    }
    static create(record){
        let object=new logicModel();
        if(!!record){
            object.setRecord(record);
        };
        return object;
    }
    /**
     * 新增模板
     * @returns {{features: *[], comments: string, web: {}, values: {}, className: string, published: string, type: string, version: string, hier: *[], others: {}}}
     */
    static tpl(){
        return {
            // id: "",
            type:"",
            className:"",
            version: "1.0",
            published: true,
            features:[],
            values:{
                "general": [
                    {propertyName:"name", propertyType:"String",defaultValue:"",filter:"false", comments:""},
                ]
            },
            hier:[{basic:[]}],
            web:{},
            others:{basic:[]},
            // createTime: dayjs.localeData(),
            // updateTime: (new Date()).toLocaleDateString(),
            comments: ""
        }
    }
    static hierTpl(type){
        return {
            logicDictionary:{
                basic:[
                    {
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ],
            },
            logicQueue:{
                basic:[
                    {
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ],
            },
            logicTree:{
                basic:[
                    {
                        id:'',
                        parentId:'',
                        name:'',
                        title:'',
                        model:'',
                        pointer:{},
                        values:{}
                    }
                ],
            },
            logicSingleton:{
                basic:{
                    name:'',
                    title:'',
                    model:'',
                    pointer:{},
                    values:{}
                },
            },
        }[type]
    }
}
